/*
 * @Author: wfl
 * @LastEditors: wfl
 * @description: 
 * @updateInfo: 本次更新内容：
 * @Date: 2021-04-28 16:52:40
 * @LastEditTime: 2021-04-29 15:44:06
 */
import { } from 'vue'
import { Chunk } from '/@/utils'

// 获取已上传、未上传文件
/**
 * @description: 
 * @param {Chunk} waitFiles 当前切片数据
 * @param {string} upedFiles 已上传文件md5数组
 * @return {handLoadList, waitList}
 */
export function useFilechunkFilter(waitFiles: Chunk[], upedFiles: string[]) {
    let handLoadList: Chunk[] = [];
    let waitList: Chunk[] = [];

    waitList = waitFiles.filter((file: Chunk) => {
        const index = upedFiles.findIndex((fileHash: string) => {
            return fileHash === file.fileMd5No
        })
        index > -1 && handLoadList.push(file);
        return index === -1
    })

    return {
        handLoadList,
        waitList
    }
}